package com.framework.model.common;

import com.framework.common.annotation.QueryParam;
import com.framework.common.model.validation.ValidationGroup;
import com.framework.common.util.other.NumeralUtil;
import com.framework.model.base.BaseModel;
import java.io.Serializable;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * @author 龘鵺
 * @version 1.0
 * @className com.framework.model.common.DataSourceConfig
 * @title 数据源配置类
 * @datetime 2025-05-06 14:13:10
 */
public class DataSourceConfig extends BaseModel implements Serializable {
    /**
     * 启用状态 ENABLE_STATUS
     */
    @NotNull(message = "请选择启用状态", groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class})
    @Min(message = "启用状态错误", value = NumeralUtil.POSITIVE_ONE, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class})
    @Max(message = "启用状态错误", value = Integer.MAX_VALUE, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class})
    @QueryParam(name = "enableStatus", code = "p.ENABLE_STATUS")
    private Integer enableStatus;

    /**
     * 数据源名称 NAME
     */
    @NotBlank(message = "请输入数据源名称", groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class})
    @Size(message = "数据源名称最多255字符", max = 255, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @QueryParam(name = "name", code = "p.NAME")
    private String name;

    /**
     * 数据源编码 CODE
     */
    @NotBlank(message = "请输入数据源编码", groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class})
    @Size(message = "数据源编码最多64字符", max = 64, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @QueryParam(name = "code", code = "p.CODE")
    private String code;

    /**
     * 连接 CONNECT_ADDRESS
     */
    @NotBlank(message = "请输入连接", groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class})
    @Size(message = "连接最多2000字符", max = 2000, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class})
    @QueryParam(name = "connectAddress", code = "p.CONNECT_ADDRESS")
    private String connectAddress;

    /**
     * 帐号 ACCOUNT
     */
    @NotBlank(message = "请输入帐号", groups = {ValidationGroup.formAdd.class})
    @Size(message = "帐号最多255字符", max = 255, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @QueryParam(name = "account", code = "p.ACCOUNT")
    private String account;

    /**
     * 密码 PASSWORD
     */
    @NotBlank(message = "请输入密码", groups = {ValidationGroup.formAdd.class})
    @Size(message = "密码最多255字符", max = 255, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class})
    @QueryParam(name = "password", code = "p.PASSWORD")
    private String password;

    /**
     * 驱动程序类 DRIVER_CLASS
     */
    @NotBlank(message = "请输入驱动程序类", groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class})
    @Size(message = "驱动程序类最多512字符", max = 512, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class})
    @QueryParam(name = "driverClass", code = "p.DRIVER_CLASS")
    private String driverClass;

    /**
     * t_data_source_config
     */
    private static final long serialVersionUID = 1L;

    public Integer getEnableStatus() {
        return enableStatus;
    }

    public void setEnableStatus(Integer enableStatus) {
        this.enableStatus = enableStatus;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code == null ? null : code.trim();
    }

    public String getConnectAddress() {
        return connectAddress;
    }

    public void setConnectAddress(String connectAddress) {
        this.connectAddress = connectAddress == null ? null : connectAddress.trim();
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account == null ? null : account.trim();
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password == null ? null : password.trim();
    }

    public String getDriverClass() {
        return driverClass;
    }

    public void setDriverClass(String driverClass) {
        this.driverClass = driverClass == null ? null : driverClass.trim();
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", enableStatus=").append(enableStatus);
        sb.append(", name=").append(name);
        sb.append(", code=").append(code);
        sb.append(", connectAddress=").append(connectAddress);
        sb.append(", account=").append(account);
        sb.append(", password=").append(password);
        sb.append(", driverClass=").append(driverClass);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        DataSourceConfig other = (DataSourceConfig) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
                && (this.getCreateId() == null ? other.getCreateId() == null : this.getCreateId().equals(other.getCreateId()))
                && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
                && (this.getOperaterId() == null ? other.getOperaterId() == null : this.getOperaterId().equals(other.getOperaterId()))
                && (this.getOperaterTime() == null ? other.getOperaterTime() == null : this.getOperaterTime().equals(other.getOperaterTime()))
                && (this.getOperaterStatus() == null ? other.getOperaterStatus() == null : this.getOperaterStatus().equals(other.getOperaterStatus()))
                && (this.getEnableStatus() == null ? other.getEnableStatus() == null : this.getEnableStatus().equals(other.getEnableStatus()))
                && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
                && (this.getCode() == null ? other.getCode() == null : this.getCode().equals(other.getCode()))
                && (this.getConnectAddress() == null ? other.getConnectAddress() == null : this.getConnectAddress().equals(other.getConnectAddress()))
                && (this.getAccount() == null ? other.getAccount() == null : this.getAccount().equals(other.getAccount()))
                && (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
                && (this.getDriverClass() == null ? other.getDriverClass() == null : this.getDriverClass().equals(other.getDriverClass()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getCreateId() == null) ? 0 : getCreateId().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getOperaterId() == null) ? 0 : getOperaterId().hashCode());
        result = prime * result + ((getOperaterTime() == null) ? 0 : getOperaterTime().hashCode());
        result = prime * result + ((getOperaterStatus() == null) ? 0 : getOperaterStatus().hashCode());
        result = prime * result + ((getEnableStatus() == null) ? 0 : getEnableStatus().hashCode());
        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
        result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode());
        result = prime * result + ((getConnectAddress() == null) ? 0 : getConnectAddress().hashCode());
        result = prime * result + ((getAccount() == null) ? 0 : getAccount().hashCode());
        result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
        result = prime * result + ((getDriverClass() == null) ? 0 : getDriverClass().hashCode());
        return result;
    }
}